package voole;

import android.content.Context;
import android.util.Log;

import com.vooleglib.InitManager;
import com.vooleglib.PhoneProxyManager;

/**
 * Created by StormSun on 23,七月,2016
 */
public class VooleProxyManager {

    /**
     * 启动代理
     */
    public static void startProxy() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    if (PhoneProxyManager.GetInstance().isProxyRunning()) {
                        PhoneProxyManager.GetInstance().exitProxy();
                        PhoneProxyManager.GetInstance().startProxy();
                    } else {
                        PhoneProxyManager.GetInstance().startProxy();
                    }

                    Log.w("syt","proxy end >>> end");
                } catch (Exception e) {
                    Log.w("syt","proxy error >>> error", e);
                    e.printStackTrace();
                }
            }
        }).start();
    }



    public static void finishPlay(){
        new Thread(new Runnable() {
            @Override
            public void run() {
                PhoneProxyManager.GetInstance().finishPlay();
            }
        }).start();
    }

    /**
     * 初始化代理
     */
    public static void initVooleProxy(Context context) {
        InitManager.GetInstance(context).init(true, "18080", true,false);
        VooleProxyManager.startProxy();
    }

    public static void exitVooleProxy(){
        PhoneProxyManager.GetInstance().exitProxy();
    }
}
